<!--分析报告 周报 -->
<template>
  <el-card class="card">
    <el-form :model="eddForm" ref="eddFormRef" :inline="true">
      <el-form-item label="日期">
        <el-col :span="11">
          <el-date-picker
            v-model="eddForm.queryTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            clearable size="small"
            :picker-options="pickerOptions0"
          >
          </el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="small" @click="searchItem()">查询</el-button>
      </el-form-item>
    </el-form>
    <p class="bg-purple">周报列表</p>
    <el-table stripe :data="tableData" class="el-table-box">
      <el-table-column
        prop="analysisName"
        label="名称"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        align="center"
      ></el-table-column>

      <el-table-column label="操作" align="center" prop="id">
        <template slot-scope="scope">
          <el-button type="text" size="small">预览</el-button>
          <el-button type="text" size="small" @click="delStation(scope.row.id)"
            >下载</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-row type="flex" justify="end">
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="query.page"
        :page-sizes="[10, 15]"
        :page-size="query.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-row>
    <previewer
      ref="preview"
      :visible.sync="showDoc"
      @loading="showDoc = true"
      @exit="onExit"
    ></previewer>
  </el-card>
</template>

<script>
import { getAnalysisReportListByPage } from "../../api/fenxi";
import Previewer from "../../components/file-list/Previewer.vue";
export default {
  // name: "WeeklyReport",
  components: { Previewer },
  data() {
    return {
      pickerOptions0: {
        disabledDate(time) {
          return time.getTime() > Date.now(); //如果没有后面的-8.64e6就是不可以选择今天的
        },
      },
      showDoc: false,
      eddForm: {
        queryTime: "",
      },
      query: {
        page: 1,
        pagesize: 10,
      },

      total: null,
      analysisType: "2",
      tableData: [],
      src: "",
      yuming:
        "http://10.200.1.2:8080/enterprise//analysis/viewAnalysisReport?id=",
      yumings:
        "http:/10.200.1.2:8080/enterprise//analysis/downloadAnalysisReport?id=",
    };
  },
  created() {
    this.getlist();
  },
  methods: {
    onExit() {
      this.showDoc = false;
    },
    //预览
    handleEdit(row) {
      this.showDoc = true;
      this.src =
        this.yuming + row.id + "&fullfilename=" + ".docx" + row.originName;
      this.$refs.preview.$emit("reload", "", "", this.src);
      console.log(this.src);
    },
    handleSizeChange(val) {
      this.query.pagesize = val;
      // this.getStaionListPage();
    },
    handleCurrentChange(val) {
      this.query.page = val;
      // this.getStaionListPage();
    },
    //表格
    async getlist() {
      await getAnalysisReportListByPage({
        analysisType: this.analysisType,
        pageCount: this.query.page,
        pageSize: this.query.pagesize,
      }).then((res) => {
        if (res.resultCode == "200") {
          console.log(res);
          this.total = res.parameter.total;
          this.tableData = res.parameter.list;
        } else {
          // this.$message({
          //   message: "暂无数据",
          //   offset: 400,
          //   duration: 1000,
          // });
          this.tableData = [];
        }
      });
    },

    //查询
    async searchItem() {
      await getAnalysisReportListByPage({
        analysisType: this.analysisType,
        pageCount: this.query.page,
        pageSize: this.query.pagesize,
        queryTime: this.eddForm.queryTime,
      }).then((res) => {
        console.log(res);
        if (res.resultCode == 200) {
          // this.$message({
          //   message: "查询成功",
          //   type: "error",
          //   offset: 450,
          //   duration: 1000,
          // });
          this.total = res.parameter.total;
          this.tableData = res.parameter.list;
        } else {
          this.$message({
            message: "暂无数据",
            offset: 450,
            duration: 1000,
          });
          this.tableData = [];
        }
      });
    },

    //下载
    delStation(row) {
      if (row > 0) {
        window.open(this.yumings + row);
        return false;
      }
    },
  },
};
</script>

<style scoped>
.content {
  margin-left: 200px;
}

.basicstyle {
  width: 1050px;
  margin-left: 40px;
}

.el-card__body {
  padding: 0 20px 20px 20px;
}

.el-form-item {
  margin-bottom: 12px;
}

.card {
  margin-top: 8px;
  height: 90.5vh;
  margin-right: 8px;
}
.bg-purple {
  background: #d3dce6;
  height: 30px;
  font-size: 14px;
  line-height: 30px;
  padding-left: 10px;
}
.el-table-box {
  display: block;
  height: 69vh;
  overflow-y: auto;
  margin-bottom: 20px;
}
.el-table::before {
  z-index: inherit;
}
</style>
